package ru.efimmatytsin.tweeterella.converters;

import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
import ru.efimmatytsin.tweeterella.entities.Photo;
import ru.efimmatytsin.tweeterella.viewmodels.PhotoViewModel;

/**
 * Created by Efim Matytsin on 28.02.15.
 */
@Component
public class PhotoViewModelConverter implements Converter<Photo,PhotoViewModel> {
    @Override
    public PhotoViewModel convert(Photo photo) {
        PhotoViewModel photoViewModel = new PhotoViewModel();
        photoViewModel.setId(photo.getId().toString());
        photoViewModel.setCreated(photo.getCreated());
        photoViewModel.setOwnerId(photo.getOwner().getId().toString());
        photoViewModel.setSubject(photo.getSubject());
        photoViewModel.setUrl(photo.getUrl());
        return photoViewModel;
    }
}
